<?php
/* @var $this SiteController */

$this->pageTitle=Yii::app()->name;
$currentLanguage = Yii::app()->language;
?>
<div id="content" class="clearfix">
<div class="top-wrapper">
    <div class="top">
        <div class="top-inner">
            <div id="rev-slider-widget-2" class="widget widget_revslider"></div>        </div><!-- /.top-inner -->
    </div><!-- /.top -->
</div><!-- /.top-wrapper -->

<div class="container">
<div class="row">



<div id="main" class="span9">
<h1 class="page-header"><?php echo $dataProp['name_'.$currentLanguage]; ?></h1>

<div class="carousel property">
    <div class="preview">


        <a class="active colorbox gallery" id="slide-1" href="http://wp.realia.byaviators.com/wp-content/uploads/2013/05/property-large-12.jpg">
            <img src="<?php echo '/uploads/'.$dataProp['id'].'/thumb_870/'.$dataProp['image']; ?>" alt="">
        </a>


        <?php
        $i=1;
        foreach($images as $image){
            $i++;
            echo'
            <a class="colorbox gallery" id="slide-'.$i.'" href="/uploads/'.$dataProp['id'].'/images/'.$image['image'].'">
            <img src="/uploads/'.$dataProp['id'].'/images/thumb_870/'.$image['image'].'" alt="">
            </a>
            ';
        }
        ?>



    </div>
    <!-- /.preview -->

    <div class="content">
        <ul>
            <li data-index="1" class="active">
                <img src="<?php echo '/uploads/'.$dataProp['id'].'/thumb_870/'.$dataProp['image']; ?>" alt="">
            </li>

            <?php
            $i=1;
            foreach($images as $image){
                $i++;
                echo'
            <li data-index="'.$i.'">
                <img src="/uploads/'.$dataProp['id'].'/images/thumb_870/'.$image['image'].'" alt="">
            </li>
            ';
            }
            ?>

        </ul>

        <a class="carousel-prev" href="#">Previous</a>
        <a class="carousel-next" href="#">Next</a>
    </div>
    <!-- /.content -->
</div><!-- /.carousel -->

<div class="property-detail">
<div class="pull-left overview">
    <div class="row">
        <div class="span3">
            <h2>Overview</h2>

            <table>
                <tbody>
                <tr>
                    <th>ID:</th>
                    <td>
                        <strong>#<?php echo $dataProp['id']; ?></strong
                    </td>
                </tr>

                <tr>
                    <th>Price:</th>
                    <td>
                        <?php echo $dataProp['price']; ?> €

                    </td>
                </tr>

                <tr>
                    <th>Type:</th>
                    <td><?php echo $dataProp['type']; ?></td>
                </tr>

                <tr>
                    <th>Contract:</th>
                    <td><?php if($dataProp['status']==0)echo 'Sold';elseif($dataProp['status']==1)echo 'Sale';elseif($dataProp['status']==2)echo 'Rent';else echo '?' ?></td>
                </tr>

                <tr>
                    <th>Location:</th>
                    <td><?php echo $dataProp['location']; ?></td>
                </tr>

                <tr>
                    <th>Bathrooms:</th>
                    <td><?php echo $dataProp['bath']; ?></td>
                </tr>

                <tr>
                    <th>Bedrooms:</th>
                    <td><?php echo $dataProp['beds']; ?></td>
                </tr>

                <tr>
                    <th>Area:</th>
                    <td><?php echo $dataProp['area']; ?>m<sup>2</sup></td>
                </tr>

                <tr>
                    <th>
                        Rating:
                    </th>
                    <td>

                        <div class="kk-star-ratings  top-left lft" data-id="86">
                            <div class="kksr-stars kksr-star gray">
                                <div class="kksr-fuel kksr-star yellow" style="width:0%;"></div>
                                <!-- kksr-fuel --><a href="#1"></a><a href="#2"></a><a href="#3"></a><a href="#4"></a><a href="#5"></a>
                            </div>
                            <!-- kksr-stars -->
                            <div class="kksr-legend"></div>
                            <!-- kksr-legend -->
                        </div>
                        <!-- kk-star-ratings -->
                        <br clear="both" />
                    </td>
                </tr>

                </tbody>
            </table>
        </div>
        <!-- /.span2 -->
    </div>
    <!-- /.row -->
</div><!-- /.overview -->
<p>
    <?php echo $dataProp['about_'.$currentLanguage]; ?>
</p>


<div class="row">
    <div class="span12">
        <?php
        $amenitiesArray=unserialize($dataProp['amenities']);
        for ($i=0;$i<31;$i++,$amenity[$i]='plain'){}
        $coutnAmenity=count($amenitiesArray);
        foreach ($amenitiesArray as $amenityArrId=>$amenityId){
            $amenity[$amenityId]='checked';
        }
        ?>
        <h2>General amenities</h2>

        <div class="row">
            <ul class="span2">
                <li class="<?php echo $amenity[0]; ?>">Air conditioning</li>
                <li class="<?php echo $amenity[1]; ?>">Balcony</li>
                <li class="<?php echo $amenity[2]; ?>">Bedding</li>
                <li class="<?php echo $amenity[3]; ?>">Cable TV</li>
                <li class="<?php echo $amenity[4]; ?>">Cleaning after exit</li>
                <li class="<?php echo $amenity[5]; ?>">Cofee pot</li>
                <li class="<?php echo $amenity[6]; ?>">Computer</li>
                <li class="<?php echo $amenity[7]; ?>">Cot</li>
            </ul><!-- /.span2 -->
            <ul class="span2">
                <li class="<?php echo $amenity[8]; ?>">Dishwasher</li>
                <li class="<?php echo $amenity[9]; ?>">DVD</li>
                <li class="<?php echo $amenity[10]; ?>">Fan</li>
                <li class="<?php echo $amenity[11]; ?>">Fridge</li>
                <li class="<?php echo $amenity[12]; ?>">Grill</li>
                <li class="<?php echo $amenity[13]; ?>">Hairdryer</li>
                <li class="<?php echo $amenity[14]; ?>">Heating</li>
                <li class="<?php echo $amenity[15]; ?>">Hi-fi</li>
            </ul><!-- /.span2 -->
            <ul class="span2">
                <li class="<?php echo $amenity[16]; ?>">Internet</li>
                <li class="<?php echo $amenity[17]; ?>">Iron</li>
                <li class="<?php echo $amenity[18]; ?>">Juicer</li>
                <li class="<?php echo $amenity[19]; ?>">Lift</li>
                <li class="<?php echo $amenity[20]; ?>">Microwave</li>
                <li class="<?php echo $amenity[21]; ?>">Oven</li>
                <li class="<?php echo $amenity[22]; ?>">Parking</li>
                <li class="<?php echo $amenity[23]; ?>">Parquet</li>
            </ul><!-- /.span2 -->
            <ul class="span2">
                <li class="<?php echo $amenity[24]; ?>">Radio</li>
                <li class="<?php echo $amenity[25]; ?>">Roof terrace</li>
                <li class="<?php echo $amenity[26]; ?>">Smoking allowed</li>
                <li class="<?php echo $amenity[27]; ?>">Terrace</li>
                <li class="<?php echo $amenity[28]; ?>">Toaster</li>
                <li class="<?php echo $amenity[29]; ?>">Towelwes</li>
                <li class="<?php echo $amenity[30]; ?>">Use of pool</li>
                <li class="<?php echo $amenity[31]; ?>">Video</li>
            </ul><!-- /.span2 -->
        </div>
        <!-- /.row -->
    </div>
    <!-- /.span12 -->
</div><!-- /.row -->

<h2>Map</h2>

<div id="property-map"></div>

<script type="text/javascript">
    jQuery(document).ready(function ($) {
        function LoadMapProperty() {
            var locations = new Array(
                [<?php echo $dataProp['latitude']; ?>, <?php echo $dataProp['longitude']; ?>]
            );
            var types = new Array(
                'condo'
            );
            var markers = new Array();
            var plainMarkers = new Array();

            var mapOptions = {
                center     : new google.maps.LatLng(<?php echo $dataProp['latitude']; ?>, <?php echo $dataProp['longitude']; ?>),
                zoom       : 14,
                mapTypeId  : google.maps.MapTypeId.ROADMAP,
                scrollwheel: false
            };

            var map = new google.maps.Map(document.getElementById('property-map'), mapOptions);

            $.each(locations, function (index, location) {
                var marker = new google.maps.Marker({
                    position: new google.maps.LatLng(location[0], location[1]),
                    map     : map,
                    icon    : 'http://wp.realia.byaviators.com/wp-content/themes/realia/assets/img/marker-transparent.png'
                });

                var myOptions = {
                    draggable             : true,
                    content               : '<div class="marker ' + types[index] + '"><div class="marker-inner"></div></div>',
                    disableAutoPan        : true,
                    pixelOffset           : new google.maps.Size(-21, -58),
                    position              : new google.maps.LatLng(location[0], location[1]),
                    closeBoxURL           : "",
                    isHidden              : false,
                    // pane: "mapPane",
                    enableEventPropagation: true
                };
                marker.marker = new InfoBox(myOptions);
                marker.marker.isHidden = false;
                marker.marker.open(map, marker);
                markers.push(marker);
            });

            google.maps.event.addListener(map, 'zoom_changed', function () {
                $.each(markers, function (index, marker) {
                    marker.infobox.close();
                });
            });
        }

        google.maps.event.addDomListener(window, 'load', LoadMapProperty);

        var dragFlag = false;
        var start = 0, end = 0;

        function thisTouchStart(e) {
            dragFlag = true;
            start = e.touches[0].pageY;
        }

        function thisTouchEnd() {
            dragFlag = false;
        }

        function thisTouchMove(e) {
            if (!dragFlag) return;
            end = e.touches[0].pageY;
            window.scrollBy(0, ( start - end ));
        }

        document.getElementById("property-map").addEventListener("touchstart", thisTouchStart, true);
        document.getElementById("property-map").addEventListener("touchend", thisTouchEnd, true);
        document.getElementById("property-map").addEventListener("touchmove", thisTouchMove, true);
    });

</script>
</div>

<div id="comments" class="comments-area">


</div><!-- /#comments -->

</div><!-- /#main -->

<div class="sidebar span3">
<div id="enquireproperties_widget-2" class="widget enquire">

    <h2>Enquire Now</h2>

    <div class="content">
        <form method="post" action="">
            <input type="hidden" name="form_id" value="enquire-form">

            <div class="control-group hidden">
                <div class="controls">
                    <input type="text" id="inputName" name="full_name">
                </div>
                <!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="control-group">
                <label class="control-label" for="inputName">
                    Name
                    <span class="form-required" title="This field is required.">*</span>
                </label>

                <div class="controls">
                    <input type="text" id="inputName" name="name" required="required">
                </div>
                <!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="control-group">
                <label class="control-label" for="inputPhone">
                    Phone
                    <span class="form-required" title="This field is required.">*</span>
                </label>

                <div class="controls">
                    <input type="text" id="inputPhone" name="phone" required="required">
                </div>
                <!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="control-group">
                <label class="control-label" for="inputDate">
                    Date
                    <span class="form-required" title="This field is required.">*</span>
                </label>

                <div class="controls">
                    <input type="date" id="inputDate" name="date" required="required">
                </div>
                <!-- /.controls -->
            </div><!-- /.control-group -->



            <div class="control-group">
                <label class="control-label" for="inputEmail">
                    Email
                    <span class="form-required" title="This field is required.">*</span>
                </label>

                <div class="controls">
                    <input type="email" id="inputEmail" name="email" required="required">
                </div>
                <!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="control-group">
                <label class="control-label" for="inputMessage">
                    Message
                    <span class="form-required" title="This field is required.">*</span>
                </label>

                <div class="controls">
                    <textarea id="inputMessage" name="message" required="required"></textarea>
                </div>
                <!-- /.controls -->
            </div><!-- /.control-group -->

            <div class="form-actions">
                <input type="hidden" name="post_id" value="86">
                <button class="btn btn-primary arrow-right">Send</button>
            </div>
            <!-- /.form-actions -->
        </form>
    </div><!-- /.content -->

</div>    <div id="assignedagents_widget-2" class="widget our-agents">

    <h2>Assigned Agents</h2>

    <div class="content">
        <div class="agent clearfix">
            <div class="image">
                <a href="http://wp.realia.byaviators.com/agents/john-connor/">
                    <img width="140" height="141" src="http://wp.realia.byaviators.com/wp-content/uploads/2013/05/john-small.png" class="attachment-post-thumbnail wp-post-image" alt="john-small" />
                </a>
            </div>
            <!-- /.image -->

            <div class="name">
                <a href="http://wp.realia.byaviators.com/agents/john-connor/">John Connor</a>
            </div>
            <!-- /.name -->
            <div class="phone">666-999-888</div>
            <!-- /.phone -->
            <div class="email"><a href="mailto:connor@example.com">connor@example.com</a>
            </div>
            <!-- /.email -->
        </div><!-- /.agent -->
        <div class="agent clearfix">
            <div class="image">
                <a href="http://wp.realia.byaviators.com/agents/martin-crane/">
                    <img width="140" height="141" src="http://wp.realia.byaviators.com/wp-content/uploads/2013/05/emma-small.png" class="attachment-post-thumbnail wp-post-image" alt="emma-small" />
                </a>
            </div>
            <!-- /.image -->

            <div class="name">
                <a href="http://wp.realia.byaviators.com/agents/martin-crane/">Sarah Connor</a>
            </div>
            <!-- /.name -->
            <div class="phone">222-333-444</div>
            <!-- /.phone -->
            <div class="email"><a href="mailto:martin@example.com">martin@example.com</a>
            </div>
            <!-- /.email -->
        </div><!-- /.agent -->
    </div><!-- /.content -->

</div>

<div id="featuredproperties_widget-4" class="widget properties">

    <h2>Featured</h2>

    <div class="content">
        <?php
        $rectntProperty=(Controller::recentPropertyes());
        foreach ($rectntProperty as $property){
            echo'
                            <div class="property">
                                <div class="image">
                                    <a href="/site/property/id/'.$property['id'].'"></a>
                                    <img src="/uploads/'.$property['id'].'/thumb_240/'.$property['image'].'" alt="3412 Cloudcroft Dr">
                                </div>
                                <div class="wrapper">
                                    <div class="title">
                                        <h3><a href="/site/property/id/'.$property['id'].'">
                                                '.$property['name_'.$this->currentLanguage].'
                                            </a></h3>
                                    </div>
                                    <div class="location">'.$property['location'].'</div>
                                    <div class="price">
                                        '.$property['price'].' €                                             </div>
                                </div>
                            </div>
                                ';
        }
        ?>
        </div>            </div><!-- /.content -->

</div>

</div><!-- /#sidebar -->
</div><!-- /.row -->

<div class="content-bottom-wrapper">
    <div class="content-bottom">
        <div class="content-bottom-inner">
        </div><!-- /.content-bottom-inner -->
    </div><!-- /.content-bottom -->
</div><!-- /.content-bottom-wrapper -->
</div><!-- /.container -->

</div><!-- /#content -->
</div><!-- /#wrapper-inner -->